/*
 * @Author: ylq
 * @Date: 2022-09-19 11:45:52
 * @Desc: 子路由
 * @Last Modified by: ylq
 * @Last Modified time: 2022-09-19 15:44:26
 */
const sub = import.meta.glob('./sub/*.js', { eager: true });

function formatRoute(_sub, result) {
  Object.keys(_sub).forEach((key) => {
    const defaultRoute = _sub[key].default;
    if (!defaultRoute) return;
    const subRouteList = Array.isArray(defaultRoute) ? [...defaultRoute] : [defaultRoute];
    result.push(...subRouteList);
  });
  return result;
}

export const appRoutes = formatRoute(sub, []);
